USE [TOM_MS]
GO

/****** Object:  StoredProcedure [dbo].[cuanhisStatus]    Script Date: 12/22/2011 01:21:57 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[cuanhisStatus]
	/*
	(
	@parameter1 int = 5,
	@parameter2 datatype OUTPUT
	)
	*/
AS
	/* SET NOCOUNT ON */
	Select CU_AN_HIS.CHOAN_ID as choanID,CU_AN_HIS.ACTUAL_AMOUNT as actualAmount, PARAM_STATUS.STATUS_NAME as statusName FROM 
	PARAM_STATUS INNER JOIN CU_AN_HIS ON PARAM_STATUS.STATUS_ID = CU_AN_HIS.STATUS_ID
	INNER JOIN CHOAN_LOG ON CHOAN_LOG.CHOAN_ID = CU_AN_HIS.CHOAN_ID
	RETURN

GO

USE [TOM_MS]
GO

/****** Object:  StoredProcedure [dbo].[getChoAnLog]    Script Date: 12/22/2011 01:22:07 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[getChoAnLog]
	/*
	(
	@parameter1 int = 5,
	@parameter2 datatype OUTPUT
	)
	*/
AS
	/* SET NOCOUNT ON */
	SELECT     AO.AO_NAME as aoName, CHOAN_LOG.AGE as age, AO_DOKIEM.VALUE as doKiem, AO_DO_TRONG.VALUE AS doTrong, AO_DOMAN.VALUE AS doMan, AO_MAU.VALUE AS mau, 
                      HIENTUONG.HIENTUONG_NAME as hienTuong, AO_BOD.VALUE AS bod, AO_COD.VALUE AS cod, AO_DO.VALUE AS hoaTan, 
                      AO_TOM_STATUS.TOM_STATUS_NAME as tomStatus, AO_TOM_SIZE.VALUE AS tomSize, CHOAN_LOG.NOTE as note,CHOAN_LOG.CHOAN_ID as choanID,
                      AO_PH.PH_SANG as phSang, AO_PH.PH_CHIEU as phChieu,FOOD.FOOD_CODE as foodCode
FROM AO INNER JOIN
                      CHOAN_LOG ON AO.AO_ID = CHOAN_LOG.AO_ID INNER JOIN
                      AO_BOD ON CHOAN_LOG.CHOAN_ID = AO_BOD.CHOAN_LOG_ID INNER JOIN
                      AO_COD ON CHOAN_LOG.CHOAN_ID = AO_COD.CHOAN_LOG_ID INNER JOIN
                      AO_DO_TRONG ON CHOAN_LOG.CHOAN_ID = AO_DO_TRONG.CHOAN_LOG_ID INNER JOIN
                      AO_DOKIEM ON CHOAN_LOG.CHOAN_ID = AO_DOKIEM.CHOAN_LOG INNER JOIN
                      AO_DOMAN ON CHOAN_LOG.CHOAN_ID = AO_DOMAN.CHOAN_LOG_ID INNER JOIN
                      AO_MAU ON CHOAN_LOG.CHOAN_ID = AO_MAU.CHOAN_LOG_ID INNER JOIN
                      AO_TOM_SIZE ON CHOAN_LOG.CHOAN_ID = AO_TOM_SIZE.CHOAN_ID INNER JOIN
                      AO_TOM_STATUS ON CHOAN_LOG.CHOAN_ID = AO_TOM_STATUS.CHOAN_LOG_ID INNER JOIN
                      AO_DO ON CHOAN_LOG.CHOAN_ID = AO_DO.CHOAN_LOG_ID INNER JOIN
                      HIENTUONG ON CHOAN_LOG.CHOAN_ID = HIENTUONG.CHOAN_LOG INNER JOIN FOOD ON CHOAN_LOG.FOOD_CODE = FOOD.FOOD_CODE
                      INNER JOIN AO_PH ON AO_PH.CHOAN_ID = CHOAN_LOG.CHOAN_ID
	RETURN

GO
USE [TOM_MS]
GO

/****** Object:  StoredProcedure [dbo].[getCuanStatus]    Script Date: 12/22/2011 01:22:32 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[getCuanStatus]
	/*
	(
	@parameter1 int = 5,
	@parameter2 datatype OUTPUT
	)
	*/
AS
	/* SET NOCOUNT ON */
	Select STATUS_NAME as cuanStatus from PARAM_STATUS
	RETURN

GO

USE [TOM_MS]
GO

/****** Object:  StoredProcedure [dbo].[getStatus]    Script Date: 12/22/2011 01:22:49 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[getStatus]
	/*
	(
	@parameter1 int = 5,
	@parameter2 datatype OUTPUT
	)
	*/
AS
	/* SET NOCOUNT ON */
	Select STATUS_NAME as cuanStatus from PARAM_STATUS
	RETURN

GO
USE [TOM_MS]
GO

/****** Object:  StoredProcedure [dbo].[insertToCalandCuan]    Script Date: 12/22/2011 01:23:02 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[insertToCalandCuan]
	/*
	(
	@parameter1 int = 5,
	@parameter2 datatype OUTPUT
	)
	*/
	@CU_AN_ID int,
	@CU_AN_TIME int,
	@CUAN_NAME nvarchar(200),
	@NOTE nvarchar(200)
AS
	/* SET NOCOUNT ON */
	INSERT INTO dbo.CU_AN(CU_AN_TIME,CUAN_NAME,NOTE) VALUES (@CU_AN_TIME,@CUAN_NAME,@NOTE)
	INSERT INTO dbo.CALENDAR(CU_AN_NAME) VALUES (@CUAN_NAME)
	RETURN

GO

USE [TOM_MS]
GO

/****** Object:  StoredProcedure [dbo].[getFoodCode]    Script Date: 12/22/2011 01:23:11 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[getFoodCode]
	/*
	(
	@parameter1 int = 5,
	@parameter2 datatype OUTPUT
	)
	*/
AS
	/* SET NOCOUNT ON */
	Select FOOD_CODE as foodCode FROM FOOD
	RETURN

GO






